package cn.ecnu.service.impl;


import cn.ecnu.mapper.FavoriteMapper;
import cn.ecnu.pojo.Favorite;
import cn.ecnu.service.FavoriteService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class FavoriteServiceImpl extends ServiceImpl<FavoriteMapper, Favorite> implements FavoriteService {
    @Override
    public boolean isUserFollowingConference(Long userId, Long conferenceId) {
        QueryWrapper<Favorite> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId).eq("conference_id", conferenceId);
        return count(queryWrapper) > 0;
    }

    @Override
    public boolean isUserFollowingJournal(Long userId, Long journalId) {
        QueryWrapper<Favorite> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId).eq("journal_id", journalId);
        return count(queryWrapper) > 0;
    }
}

